//
//  HMBlueToothManager.h
//  03-蓝牙开发
//
//  Created by HM09 on 2017/4/26.
//  Copyright © 2017年 itheima. All rights reserved.
//

#import <Foundation/Foundation.h>

#import <CoreBluetooth/CoreBluetooth.h>

#define kHMBlueToothManager [HMBlueToothManager shareInstance]

@interface HMBlueToothManager : NSObject


+ (instancetype)shareInstance;


/**
 开始扫描外设

 @param updatePeripheral 扫描外设回调
 */
- (void)beginScanCBPeripheral:(void(^)(NSArray *peripheralArr))updatePeripheral;



/**
 连接设备

 @param peripheral 外设
 @param completionBlock 连接回调
 */
- (void)connectPeripheral:(CBPeripheral *)peripheral Completion:(void(^)(NSError *))completionBlock;
/**
 断开连接
 
 @param peripheral 外设
 @param discompletionBlock 连接回调
 */
- (void)disconnectPeripheral:(CBPeripheral *)peripheral Completion:(void(^)(NSError *))discompletionBlock;


/**
 发送命令
 */
- (void) sendData:(NSData *)data;

-(void)sendMsgWithSubPackage:(NSData*)msgData;
/**
 蓝牙返回数据
 
 @param array 返回数据
 */
typedef void (^BLEDataBlock)(NSData *value);
@property (nonatomic,copy) BLEDataBlock dataBlock;

//写入失败回调
typedef void (^WriteFailure)(NSString *value);
@property (nonatomic,strong) WriteFailure failureBlock;

//蓝牙连接断开回调
typedef void (^BluetoothConnectionDisconnect)(NSString *value);
@property (nonatomic,strong) BluetoothConnectionDisconnect bluetoothConnectionDisconnect;

@end
